package cn.stl.basic.util;

import lombok.Data;

/**
 * 返回json对象
 */
@Data
public class AjaxResult {

    private Boolean success = true;

    private String message = "ok";

    /**
     * 链式语法
     */
    public AjaxResult setSuccess(Boolean success){
        this.success = success;
        return this;
    }

    /**
     * 链式语法
     */
    public AjaxResult setMessage(String message){
        this.success = false;
        this.message = message;
        return this;
    }

    /**
     * 返回默认对象
     */
    public static AjaxResult me(){
        return new AjaxResult();
    }

    //tupide
    public static AjaxResult createSuccess(){
        return new AjaxResult();
    }

    public static AjaxResult createError(String message){
        return AjaxResult.me().setMessage(message);
    }

    public static AjaxResult createError(){
        return AjaxResult.me().setMessage("网络繁忙,请稍候再试");
    }

}
